function printpdf(name)

opts = ['GS_OPTIONS="',...
        '-dPDFSETTINGS=/printer ',                  ...
        '-dAutoFilterGrayImages=false ',            ...
        '-dGrayImageFilter=/FlateEncode ',          ...
        '-dAutoFilterColorImages=false ',           ...
        '-dColorImageFilter=/FlateEncode ',         ...
        '-dMaxSubsetPct=100 ',                      ...
        '-dSubsetFonts=true ',                      ...
        '-dEmbedAllFonts=true ',                    ...
        '-dCompatibilityLevel=1.4 ',                ...
        '" '] ;


print('-depsc', [name '.eps']) ;
cmd = sprintf('LD_LIBRARY_PATH= %s epstopdf %s.eps', opts, name) ;
[s,r] = unix(cmd) ;

fprintf(r)

if s
  fprintf(r) ;
  error('printpdf: error in epstopdf') ;
end

delete([name '.eps']) ;

